﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />

    <title>注册</title>

    <style>
		html, body, .container { height: 100%; overflow: hidden !important; margin: 0 0 0 0; }
		.container { display: table; width: 100% }
			.container > div { text-align: center; display: table-cell; vertical-align: middle; width: 100% }
				.container > div > div { display: inline-block; border: solid 1px skyblue; padding: 10px 10px 10px 10px }
		input { margin-bottom: 5px }
    </style>

    <script src="/web/js/jquery.351.min.js"></script>
    <script src="/web/js/common.js"></script>
    <script src="/web/js/upload.js"></script>

    <script>
        async function register()
        {
			if (/wechat/gi.test(navigator.userAgent))
			{
				alert("不支持在微信内直接打开此网站");
				return;
            }

            var acc = $("#txtAcc").val().trim(), psw = $("#txtPsw1").val(), name = $("#txtName").val().trim();

            if (acc == "" || name == "")
            {
                alert("帐号和姓名不能为空或全空格");
                return;
            }

			if (psw != $("#txtPsw2").val())
            {
                alert("两次密码不一致");
                return;
            }

			if (!/^[\x00-\x7f]+$/g.test(psw))
			{
                alert("帐号只支持数字、英文和空格且不能全是空格，密码只支持数字、英文和半角符号");
                return;
			}

			clearCookie();

            var form = new FormData();
            form.append("acc", encodeURI(acc));
            form.append("psw", psw);
            form.append("name", name);
            await request("注册", "register.ashx?cmd=register", true, { method: "POST", body: form });
			alert("注册成功，点击确定后自动登录");

            sessionStorage.clear();
			location.href = isMobile() ? "mlist.htm" : "list.htm";
		}
    </script>
</head>
<body>
    <div class="container">
        <div>
            <div onkeydown="if(event.keyCode==13) register()">
                <div><span>帐号：</span><input id="txtAcc" placeholder="登录帐号" /></div>
                <div><span>密码：</span><input id="txtPsw1" type="password" /></div>
                <div><span>密码：</span><input id="txtPsw2" type="password" placeholder="再次输入上面的密码" /></div>
                <div><span>姓名：</span><input id="txtName" placeholder="分享图片时显示的中文名" /></div>
                <div>
                    <button onclick="register()">注册</button>
                    <a href="login.htm"><button>登录</button></a>
                </div>
            </div>
        </div>
    </div>
</body>
</html>